//
//  DuoBaoInterfaceParamAndSerializer.m
//  DuoBao
//
//  Created by LinXiaoBin on 16/3/22.
//  Copyright © 2016年 aron. All rights reserved.
//

#import "BusinessInterfaceParamAndSerializer.h"

@implementation BusinessInterfaceParamAndSerializer

#pragma mark - ......::::::: FLInterfaceBusinessParamDelegate :::::::......

- (NSString *)pSessionID:(FLInterfaceForBusiness *)interface
{
//    return [[ZMUserInfo sharedInstance] getSessionid];
    // FIXME: ZYT sessionID
    return @"";
}

-(NSInteger)pUserID {
    // return [ZMUserInfo sharedInstance].zmUserInfoItem.userid;
    // FIXME: ZYT 用户ID
    return 1;
}

- (NSString*)pUserName {
//    NSString* userName = [ZMUserInfo sharedInstance].zmUserInfoItem.nickname;
//    if (userName != nil && ![userName isEmptyOrWhitespace]) {
//        return userName;
//    }
    // FIXME: ZYT 用户名
    return @"匿名用户";
}


#pragma mark - ......::::::: FLResponseSerializerDelegate :::::::......

- (id)flInterface:(FLInterfaceBase *)interface serializerResponseHeader:(NSDictionary *)header responseObject:(id)responseObject error:(NSError **)error
{
    id result = responseObject;
    NSString* oriResultStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"oriResultStr = %@", oriResultStr);
    if ([responseObject isKindOfClass:[NSData class]]) {
        result = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:NULL];
        
        NSLog(@"\nresponse datas:\n%@", result);
    }
    
    // 处理网络错误的打点
    NSError* err = *error;
    if (err) {
        // FIXME: ZYT 统一处理
        // NSString* anaLabel = [DBLogUtils genLogCarrierLabel];
        // [NdAnalytics event:DBStat_Request_Error_Network_Status label:anaLabel];
    }// ~打点结束
    
    return result;
}

@end
